import request from '@/utils/request.js'

//添加文章
export const submitArticleService = (articleData)=>{
    return request.post('/post/addPosts',articleData)
}

//获取文章列表
export const getArticleListService = (query)=>{
    return request.get('/post/getPostsList',{params:query})
}

//修改文章
export const updateArticleService = (articleData)=>{
    return request.put('/post/updatePosts',articleData)
}

//修改文章评论状态
export const updateArticleCommentStatusService = (commentStatus, id) => {
    const params = new URLSearchParams();
    params.append('commentStatus', commentStatus);
    params.append('postId', id);
    
    return request.patch('/post/updateCommentStatus', null, { 
        params
    });
}

//修改文章置顶
export const updateArticleTopService = (isTop, id) => {
    const params = new URLSearchParams();
    params.append('isTop', isTop);
    params.append('postId', id);
    return request.patch('/post/updateIsTop', null, { params }); 
}

//修改文章发布状态
export const updateArticleStatusService = (isStatus, id) => { 
    const params = new URLSearchParams();
    params.append('status', isStatus);
    params.append('postId', id);
    return request.patch('/post/updateStatus', null, { params }); 
}

//删除文章
export const deleteArticleService = (id) => { 
    return request.delete('/post/deletePosts', { params: { postId: id } });
}